package com.ruoyi.web.controller.core;

import java.util.List;

import com.ruoyi.core.domain.vo.SmsRecordVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.core.domain.SmsRecord;
import com.ruoyi.core.service.ISmsRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 快递发货短信通知记录Controller
 * 
 * @author lgc
 * @date 2020-12-01
 */
@Controller
@RequestMapping("/core/smsRecord")
public class SmsRecordController extends BaseController
{
    private String prefix = "core/smsRecord";

    @Autowired
    private ISmsRecordService smsRecordService;

    @RequiresPermissions("core:smsRecord:view")
    @GetMapping()
    public String smsRecord()
    {
        return prefix + "/smsRecord";
    }

    /**
     * 查询快递发货短信通知记录列表
     */
    @RequiresPermissions("core:smsRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SmsRecord smsRecord)
    {
        startPage();
        List<SmsRecordVo> list = smsRecordService.selectSmsRecordList(smsRecord);
        return getDataTable(list);
    }

    /**
     * 导出快递发货短信通知记录列表
     */
//    @RequiresPermissions("core:smsRecord:export")
//    @Log(title = "快递发货短信通知记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    @ResponseBody
//    public AjaxResult export(SmsRecord smsRecord)
//    {
//        List<SmsRecordVo> list = smsRecordService.selectSmsRecordList(smsRecord);
//        ExcelUtil<SmsRecord> util = new ExcelUtil<SmsRecord>(SmsRecordVo.class);
//        return util.exportExcel(list, "smsRecord");
//    }

    /**
     * 新增快递发货短信通知记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存快递发货短信通知记录
     */
    @RequiresPermissions("core:smsRecord:add")
    @Log(title = "快递发货短信通知记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SmsRecord smsRecord)
    {
        return toAjax(smsRecordService.insertSmsRecord(smsRecord));
    }

    /**
     * 修改快递发货短信通知记录
     */
    @GetMapping("/edit/{smsRecordId}")
    public String edit(@PathVariable("smsRecordId") Long smsRecordId, ModelMap mmap)
    {
        SmsRecord smsRecord = smsRecordService.selectSmsRecordById(smsRecordId);
        mmap.put("smsRecord", smsRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存快递发货短信通知记录
     */
    @RequiresPermissions("core:smsRecord:edit")
    @Log(title = "快递发货短信通知记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SmsRecord smsRecord)
    {
        return toAjax(smsRecordService.updateSmsRecord(smsRecord));
    }

    /**
     * 删除快递发货短信通知记录
     */
    @RequiresPermissions("core:smsRecord:remove")
    @Log(title = "快递发货短信通知记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(smsRecordService.deleteSmsRecordByIds(ids));
    }
}
